home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8164 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: monkeys.com!not-for-mail
  2. From: rfg@monkeys.com (Ronald F. Guilmette)
  3. Newsgroups: comp.lang.c,comp.lang.c++,gnu.gcc.help,gnu.g++.help,comp.os.msdos.djgpp
  4. Subject: Re: float != float and floats as return types
  5. Date: 15 Feb 1996 01:23:58 -0800
  6. Organization: Infinite Monkeys & Co.
  7. Message-ID: <4fuu3e$6c9@segfault.monkeys.com>
  8. References: <4ej9lb$mpc@fu-berlin.de> <4eqc7l$ugh@godzilla.zeta.org.au> <4eqtu3$ddo@der.twinsun.com> <TANMOY.96Feb1164022@qcd.lanl.gov>
  9. NNTP-Posting-Host: segfault.monkeys.com
  10.  
  11. In article <TANMOY.96Feb1164022@qcd.lanl.gov>,
  12. Tanmoy Bhattacharya <tanmoy@qcd.lanl.gov> wrote:
  13. >In article <4eqtu3$ddo@der.twinsun.com> eggert@twinsun.com (Paul
  14. >Eggert) writes: 
  15. ><snip>
  16. >   bde@zeta.org.au (Bruce Evans) writes:
  17. >
  18. >   >    a = 1.0;
  19. >   >    b = FLT_EPSILON / 4.0;
  20. >   >    c = a + b;
  21. >   >    assert(c == (float) (a + b));
  22. >
  23. >   As far as I can tell the C Standard allows the assertion to either
  24. >   succeed or fail, depending on the implementation.  The key phrase in
  25. >   the standard is ``The values of floating operands and of the results of
  26. >   floating expressions may be represented in greater precision and range
  27. >   than that required by the type''.  So `c' might be represented in more
  28. >   bits than `(float) (a + b)' (or vice versa! though this is more
  29. >   controversial since it contradicts the Rationale, and it may be
  30. >   corrected by the committee soon), and the assertion might fail.
  31. >
  32. >I do not agree with this interpretation, as the footnote (technically,
  33. >not part of the standard) clarifies: an assignment and cast both must
  34. >truncate the result to the required precision...
  35.  
  36. As must the act of returning a result from a function... according to the
  37. official response to one Defect Report which was filed against the standard.
  38.  
  39. -- 
  40.  
  41. -- Ron Guilmette, Roseville, CA -------- Infinite Monkeys & Co. ------------
  42. ---- E-mail: rfg@monkeys.com ----------- Purveyors of Compiler Test Suites -
  43. ------ Copyright (c) 1996 by Ronald F. Guilmette; All rights reserved. -----
  44.